package com.liliya.common.lang;

import lombok.Data;

/**
 * @Description 统一结果返回集
 * @Author hhy
 * @Date 2021/5/7 19:07
 */
@Data
public class Result {
    private String msg;
    private Integer code;
    private Object data;

    public static Result succ(String msg,Integer code ,Object data){
        Result result = new Result();
        result.setMsg(msg);
        result.setCode(200);
        result.setData(data);
        return result;
    }

    public static Result succ(Object data){
        return succ("请求成功！",200,data);
    }

    public static Result fail(String msg){
        Result result = new Result();
        result.setCode(400);
        result.setMsg(msg);
        result.setData(null);
        return result;
    }

    public static Result fail(String msg,Object data){
        Result result = new Result();
        result.setCode(400);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }

    public static Result fail(int code,String msg,Object data){
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }
}
